File tree Expand file tree Collapse file tree 3 files changed +21
-5
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -465,7 +465,8 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
465465 */
466466 def addTyped (arg : Arg , formal : Type ): Type => Type = {
467467 addArg(typedArg(arg, formal), formal)
468- if (methodType.isParamDependent)
468+ if (methodType.isParamDependent && typeOfArg(arg).exists)
469+ // `typeOfArg(arg)` could be missing because it's evaluation of `arg` caused errors
469470 safeSubstParam(_, methodType.paramRefs(n), typeOfArg(arg))
470471 else identity
471472 }
Original file line number Diff line number Diff line change @@ -302,11 +302,13 @@ object ProtoTypes {
302302 typer.adapt(targ, formal, locked)
303303 }
304304
305- /** The type of the argument `arg`.
306- * @pre `arg` has been typed before
305+ /** The type of the argument `arg`, `NoType` is `arg` has not been typed before
306+ * or if `arg`'s typing produced a type error.
307307 */
308- def typeOfArg (arg : untpd.Tree )(implicit ctx : Context ): Type =
309- state.typedArg(arg).tpe
308+ def typeOfArg (arg : untpd.Tree )(implicit ctx : Context ): Type = {
309+ val t = state.typedArg(arg)
310+ if (t == null ) NoType else t.tpe
311+ }
310312
311313 /** The same proto-type but with all arguments combined in a single tuple */
312314 def tupled : FunProto = state.tupled match {
Original file line number Diff line number Diff line change 1+ object m {
2+ trait Foo {
3+ type T [A ]
4+ def bar : (T [Int ] => T [Int ]) => T [Int => Int ]
5+ }
6+
7+ def baz (implicit S : Foo , f : S .T [Int ] => S .T [Int ]) : S .T [Int => Int ] =
8+ S .bar.apply(f)
9+
10+ def example (implicit s: Foo ) : s.T [Int => Int ] = {
11+ baz((x : s.T [Int ]) => x)
12+ }
13+ }
You can’t perform that action at this time.
0 commit comments