File tree 2 files changed +12
-5
lines changed
compiler/src/dotty/tools/dotc/typer
2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -3048,17 +3048,24 @@ class Typer extends Namer
3048
3048
// try an extension method in scope
3049
3049
pt match {
3050
3050
case SelectionProto (name, mbrType, _, _) =>
3051
+ val origCtx = ctx
3051
3052
def tryExtension (implicit ctx : Context ): Tree =
3052
3053
try
3053
3054
findRef(name, WildcardType , ExtensionMethod , tree.posd) match {
3054
3055
case ref : TermRef =>
3055
3056
extMethodApply(untpd.ref(ref).withSpan(tree.span), tree, mbrType)
3056
3057
case _ => EmptyTree
3057
3058
}
3058
- catch {
3059
- case ex : CyclicReference => throw ex
3060
- case ex : TypeError => errorTree(tree, ex, tree.sourcePos)
3061
- }
3059
+ catch
3060
+ case ex : CyclicReference =>
3061
+ if ex.denot.is(Extension ) && ex.denot.name == name then
3062
+ origCtx.warning(
3063
+ em """ An extension method was tried but could not be fully constructed
3064
+ |since there was a cyclic reference involving ${ex.denot.symbol.showLocated}""" ,
3065
+ tree.sourcePos)
3066
+ EmptyTree
3067
+ case ex : TypeError =>
3068
+ EmptyTree
3062
3069
val nestedCtx = ctx.fresh.setNewTyperState()
3063
3070
val app = tryExtension(nestedCtx)
3064
3071
if (! app.isEmpty && ! nestedCtx.reporter.hasErrors) {
Original file line number Diff line number Diff line change 1
1
case class Project (name : String )
2
2
def (name : String ) dependencies = ???
3
- def (project : Project ) dependencies = project.name.dependencies // error: needs return type
3
+ def (project : Project ) dependencies = project.name.dependencies // error, following a cyclic reference warning
You can’t perform that action at this time.
0 commit comments