Skip to content

Commit c1a6f88

Browse files
committed
WIP
1 parent f1ae9b3 commit c1a6f88

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,11 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
456456
// skip this member
457457
return NoSymbol
458458

459+
// Adapt the flags of getters so they become like vals/vars instead
460+
if flags.isAllOf(Method | Accessor) && !name.toString().endsWith("_$eq") then
461+
flags &~= Method | Accessor
462+
if !flags.is(StableRealizable) then flags |= Mutable
463+
459464
name = name.adjustIfModuleClass(flags)
460465
if (flags.is(Method))
461466
name =
@@ -620,7 +625,12 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
620625
setClassInfo(denot, tp, fromScala2 = true, selfInfo)
621626
NamerOps.addConstructorProxies(denot.classSymbol)
622627
case denot =>
623-
val tp1 = translateTempPoly(tp)
628+
val tp0 = translateTempPoly(tp)
629+
val tp1 =
630+
if !denot.is(Param) && !denot.is(Method) && tp0.isInstanceOf[ExprType] then
631+
tp0.asInstanceOf[ExprType].resultType
632+
else tp0
633+
624634
denot.info =
625635
if (tag == ALIASsym) TypeAlias(tp1)
626636
else if (denot.isType) checkNonCyclic(denot.symbol, tp1, reportErrors = false)

tests/neg/constructor-proxy-shadowing.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
17 |val x = Seq(3) // error: shadowing
5353
| ^^^
5454
| Reference to constructor proxy for class Seq
55-
| shadows outer reference to getter Seq in package scala
55+
| shadows outer reference to value Seq in package scala
5656
|
5757
| The instance needs to be created with an explicit `new`.
5858
|--------------------------------------------------------------------------------------------------------------------
@@ -66,7 +66,7 @@
6666
|
6767
| new Seq(...)
6868
|
69-
| Or it could mean calling the apply method of getter Seq in package scala as in
69+
| Or it could mean calling the apply method of value Seq in package scala as in
7070
|
7171
| Seq.apply(...)
7272
|

0 commit comments

Comments
 (0)