Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute isComplete together with typeParams for kind-arity check #9400

Merged
merged 1 commit into from Dec 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/compiler/scala/tools/nsc/typechecker/Typers.scala
Expand Up @@ -5535,18 +5535,17 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
}

def typedAppliedTypeTree(tree: AppliedTypeTree) = {
val tpt = tree.tpt
val args = tree.args
val tpt1 = typed1(tpt, mode | FUNmode | TAPPmode, WildcardType)
def isPoly = tpt1.tpe.isInstanceOf[PolyType]
def isComplete = tpt1.symbol.rawInfo.isComplete
val tpt = tree.tpt
val args = tree.args
val tpt1 = typed1(tpt, mode | FUNmode | TAPPmode, WildcardType)

if (tpt1.isErrorTyped) {
tpt1
} else if (!tpt1.hasSymbolField) {
AppliedTypeNoParametersError(tree, tpt1.tpe)
} else {
val tparams = tpt1.symbol.typeParams
val isComplete = tpt1.symbol.rawInfo.isComplete

if (sameLength(tparams, args)) {
// @M: kind-arity checking is done here and in adapt, full kind-checking is in checkKindBounds (in Infer)
Expand Down Expand Up @@ -5594,6 +5593,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
}
val original = treeCopy.AppliedTypeTree(tree, tpt1, args1)
val result = TypeTree(appliedType(tpt1.tpe, argtypes)) setOriginal original
val isPoly = tpt1.tpe.isInstanceOf[PolyType]
if (isPoly) // did the type application (performed by appliedType) involve an unchecked beta-reduction?
TypeTreeWithDeferredRefCheck() { () =>
// wrap the tree and include the bounds check -- refchecks will perform this check (that the beta reduction was indeed allowed) and unwrap
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
}
}