Skip to content

Commit 38b8c50

Browse files
eed3si9nWojciechMazur
authored andcommitted
Fix undercompilation upon ctor change
**Problem** Scala 3 compiler registers special `zincMangledName` for constructors for the purpose of incremental compilation. Currently the `zincMangledName` contains the package name, which does not match the use site tracking, thereby causing undercompilation during incremental compilation after a ctor change, like adding a parameter. There is an existing scripted test, but coincidentally the test class does NOT include packages, so the test ends up passing. **Solution** This PR reproduces the issue by adding package name to the test. This also fixes the problem by changing the `zincMangedName` to `sym.owner.name ++ ";init;"`. [Cherry-picked 157ed43]
1 parent 2201bcf commit 38b8c50

File tree

6 files changed

+10
-2
lines changed

6 files changed

+10
-2
lines changed

compiler/src/dotty/tools/dotc/sbt/package.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ inline val InlineParamHash = 1997 // 302nd prime
1212
extension (sym: Symbol)
1313

1414
def constructorName(using Context) =
15-
sym.owner.fullName ++ ";init;"
15+
sym.owner.name ++ ";init;"
1616

1717
/** Mangle a JVM symbol name in a format better suited for internal uses by sbt. */
1818
def zincMangledName(using Context): Name =

sbt-bridge/test/xsbt/ExtractUsedNamesSpecification.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ class ExtractUsedNamesSpecification {
306306
// All classes extend Object
307307
"Object",
308308
// All classes have a default constructor called <init>
309-
"java.lang.Object;init;",
309+
"Object;init;",
310310
// the return type of the default constructor is Unit
311311
"Unit"
312312
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
package example
2+
13
class A(a: Int)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
package example
2+
13
class B { val y = new A(2) }
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
package example
2+
13
class A(a: String)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
package example
2+
13
class B { val y = new A("a") }

0 commit comments

Comments
 (0)