Skip to content

Commit 51b29e0

Browse files
committed
Fix class vals, keep annotation loonger
1 parent 964e672 commit 51b29e0

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,10 @@ trait Applications extends Compatibility {
912912
var app = ApplyTo(tree, fun1, funRef, proto, pt)
913913
if ctx.mode.is(Mode.UnsafeJavaReturn) then
914914
val funSym = fun1.symbol
915-
if funSym.is(JavaDefined) && !funSym.isConstructor then
915+
if funSym.is(JavaDefined)
916+
&& funSym.isTerm
917+
&& funSym.is(Method)
918+
&& !funSym.isConstructor then
916919
val rtp1 = app.tpe
917920
val rtp2 = rtp1.replaceOrNull
918921
if rtp1 ne rtp2 then

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,15 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
646646

647647
def typeSelectOnTerm(using Context): Tree =
648648
val qual = typedExpr(tree.qualifier, shallowSelectionProto(tree.name, pt, this))
649-
typedSelect(tree, pt, qual).withSpan(tree.span).computeNullable()
649+
var sel = typedSelect(tree, pt, qual).withSpan(tree.span).computeNullable()
650+
if ctx.mode.is(Mode.UnsafeJavaReturn) && pt != AssignProto then
651+
val sym = sel.symbol
652+
if sym.is(JavaDefined) && sym.isTerm && !sym.is(Method) then
653+
val stp1 = sel.tpe.widen
654+
val stp2 = stp1.replaceOrNull
655+
if stp1 ne stp2 then
656+
sel = sel.cast(stp2)
657+
sel
650658

651659
def javaSelectOnType(qual: Tree)(using Context) =
652660
// semantic name conversion for `O$` in java code
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package scala.annotation
22

3-
final class CanEqualNull extends StaticAnnotation
3+
final class CanEqualNull extends RefiningAnnotation

0 commit comments

Comments
 (0)