Skip to content

Commit

Permalink
Initialize type params for kind-arity check
Browse files Browse the repository at this point in the history
The type params might have type params of their own.
  • Loading branch information
joroKr21 committed Dec 20, 2020
1 parent 1a4fa66 commit ddd7125
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/compiler/scala/tools/nsc/typechecker/Typers.scala
Expand Up @@ -5551,15 +5551,12 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
if (sameLength(tparams, args)) {
// @M: kind-arity checking is done here and in adapt, full kind-checking is in checkKindBounds (in Infer)
val args1 = map2Conserve(args, tparams) { (arg, tparam) =>
def ptParams = Kind.FromParams(tparam.typeParams)

// if symbol hasn't been fully loaded, can't check kind-arity except when we're in a pattern,
// where we can (we can't take part in F-Bounds) and must (scala/bug#8023)
val pt = if (mode.typingPatternOrTypePat) {
tparam.initialize; ptParams
}
else if (isComplete) ptParams
else Kind.Wildcard
val pt = if (mode.typingPatternOrTypePat || isComplete)
Kind.FromParams(tparam.initialize.typeParams)
else
Kind.Wildcard

typedHigherKindedType(arg, mode, pt)
}
Expand Down
8 changes: 8 additions & 0 deletions test/files/pos/t12187.scala
@@ -0,0 +1,8 @@
object Test {
trait Foo[S[_[_], _[_]]] extends Bar[S] {
def m[F[_]](x: S[({ type G[A] = Bar[S] })#G, F]): Unit
}
trait Bar[S[_[_], _[_]]] {
def m[F[_]](x: S[({ type G[A] = Bar[S] })#G, F]): Unit
}
}

0 comments on commit ddd7125

Please sign in to comment.