-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12712 from dotty-staging/fix-12401
fix #12401: mangle ctor names in ExtractAPI
- Loading branch information
Showing
15 changed files
with
71 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package dotty.tools.dotc.sbt | ||
|
||
import dotty.tools.dotc.core.Contexts.Context | ||
import dotty.tools.dotc.core.Symbols.Symbol | ||
import dotty.tools.dotc.core.NameOps.stripModuleClassSuffix | ||
import dotty.tools.dotc.core.Names.Name | ||
|
||
extension (sym: Symbol) | ||
|
||
def constructorName(using Context) = | ||
sym.owner.fullName ++ ";init;" | ||
|
||
/** Mangle a JVM symbol name in a format better suited for internal uses by sbt. */ | ||
def zincMangledName(using Context): Name = | ||
if (sym.isConstructor) constructorName | ||
else sym.name.stripModuleClassSuffix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
class A(a: Int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
class B { val y = new A(2) } |
1 change: 1 addition & 0 deletions
1
sbt-test/source-dependencies/constructors-curried/changes/A2.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
class A(a: Int)(b: String) |
1 change: 1 addition & 0 deletions
1
sbt-test/source-dependencies/constructors-curried/changes/B2.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
class B { val y = new A(2)("a") } |
12 changes: 12 additions & 0 deletions
12
sbt-test/source-dependencies/constructors-curried/project/DottyInjectedPlugin.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import sbt._ | ||
import Keys._ | ||
|
||
object DottyInjectedPlugin extends AutoPlugin { | ||
override def requires = plugins.JvmPlugin | ||
override def trigger = allRequirements | ||
|
||
override val projectSettings = Seq( | ||
scalaVersion := sys.props("plugin.scalaVersion"), | ||
scalacOptions += "-source:3.0-migration" | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
> compile | ||
$ copy-file changes/A2.scala A.scala | ||
# we should detect that A has changed, | ||
# this should trigger recompilation of B, | ||
# which should fail due to missing curried argument | ||
-> compile | ||
$ copy-file changes/B2.scala B.scala | ||
# B is updated so that it passes an extra | ||
# argument to A's constructor, it should compile | ||
> compile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
class A(a: Int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
class B { val y = new A(2) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
class A(a: String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
class B { val y = new A("a") } |
12 changes: 12 additions & 0 deletions
12
sbt-test/source-dependencies/constructors/project/DottyInjectedPlugin.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import sbt._ | ||
import Keys._ | ||
|
||
object DottyInjectedPlugin extends AutoPlugin { | ||
override def requires = plugins.JvmPlugin | ||
override def trigger = allRequirements | ||
|
||
override val projectSettings = Seq( | ||
scalaVersion := sys.props("plugin.scalaVersion"), | ||
scalacOptions += "-source:3.0-migration" | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
> compile | ||
$ copy-file changes/A2.scala A.scala | ||
# we should detect that A has changed, | ||
# this should trigger recompilation of B, | ||
# which should fail due to mismatched arguments | ||
-> compile | ||
$ copy-file changes/B2.scala B.scala | ||
# B is updated so that it passes a correct | ||
# argument to A's constructor, it should compile | ||
> compile |