From c1a6f88b6ce30ee7379b2b33799256105a4f7554 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Thu, 9 Nov 2023 15:38:33 +0100 Subject: [PATCH] WIP --- .../dotc/core/unpickleScala2/Scala2Unpickler.scala | 12 +++++++++++- tests/neg/constructor-proxy-shadowing.check | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala index 8b939f5cc47e..8687a713ba2c 100644 --- a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala @@ -456,6 +456,11 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas // skip this member return NoSymbol + // Adapt the flags of getters so they become like vals/vars instead + if flags.isAllOf(Method | Accessor) && !name.toString().endsWith("_$eq") then + flags &~= Method | Accessor + if !flags.is(StableRealizable) then flags |= Mutable + name = name.adjustIfModuleClass(flags) if (flags.is(Method)) name = @@ -620,7 +625,12 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas setClassInfo(denot, tp, fromScala2 = true, selfInfo) NamerOps.addConstructorProxies(denot.classSymbol) case denot => - val tp1 = translateTempPoly(tp) + val tp0 = translateTempPoly(tp) + val tp1 = + if !denot.is(Param) && !denot.is(Method) && tp0.isInstanceOf[ExprType] then + tp0.asInstanceOf[ExprType].resultType + else tp0 + denot.info = if (tag == ALIASsym) TypeAlias(tp1) else if (denot.isType) checkNonCyclic(denot.symbol, tp1, reportErrors = false) diff --git a/tests/neg/constructor-proxy-shadowing.check b/tests/neg/constructor-proxy-shadowing.check index f45b9b3205c3..091d1ed14c1e 100644 --- a/tests/neg/constructor-proxy-shadowing.check +++ b/tests/neg/constructor-proxy-shadowing.check @@ -52,7 +52,7 @@ 17 |val x = Seq(3) // error: shadowing | ^^^ | Reference to constructor proxy for class Seq - | shadows outer reference to getter Seq in package scala + | shadows outer reference to value Seq in package scala | | The instance needs to be created with an explicit `new`. |-------------------------------------------------------------------------------------------------------------------- @@ -66,7 +66,7 @@ | | new Seq(...) | - | Or it could mean calling the apply method of getter Seq in package scala as in + | Or it could mean calling the apply method of value Seq in package scala as in | | Seq.apply(...) |