Skip to content

Commit 2470455

Browse files
committed
Replace hasHigherKind by hasSimpleKind
hasHigherKind is misleading since it will cover AnyKind and Effect as well and it is not clear how these are "higher" kinds.
1 parent 64f2333 commit 2470455

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

compiler/src/dotty/tools/dotc/core/TypeApplications.scala

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,9 @@ class TypeApplications(val self: Type) extends AnyVal {
210210
/** Is self type bounded by a type lambda or AnyKind? */
211211
def isLambdaSub(implicit ctx: Context): Boolean = hkResult.exists
212212

213-
/** Is self type of kind != "*"? */
214-
def hasHigherKind(implicit ctx: Context): Boolean =
215-
typeParams.nonEmpty || self.hasAnyKind
216-
217213
/** Is self type of kind "*"? */
218-
def hasFirstKind(implicit ctx: Context): Boolean = !hasHigherKind
214+
def hasSimpleKind(implicit ctx: Context): Boolean =
215+
typeParams.isEmpty && !self.hasAnyKind
219216

220217
/** If self type is higher-kinded, its result type, otherwise NoType.
221218
* Note: The hkResult of an any-kinded type is again AnyKind.

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,8 @@ object Checking {
4646
*/
4747
def checkBounds(args: List[tpd.Tree], boundss: List[TypeBounds], instantiate: (Type, List[Type]) => Type)(implicit ctx: Context): Unit = {
4848
(args, boundss).zipped.foreach { (arg, bound) =>
49-
if (!bound.isLambdaSub && arg.tpe.hasHigherKind) {
49+
if (!bound.isLambdaSub && !arg.tpe.hasSimpleKind) {
5050
// see MissingTypeParameterFor
51-
if (!arg.tpe.isLambdaSub) { // FIXME: Provisional, remove
52-
println(i"different for checkBounds $arg vs $bound at ${ctx.phase} in ${ctx.owner.ownersIterator.toList}")
53-
throw new AssertionError("")
54-
}
5551
ctx.error(ex"missing type parameter(s) for $arg", arg.pos)
5652
}
5753
}
@@ -709,7 +705,7 @@ trait Checking {
709705

710706
/** Check that `tpt` does not define a higher-kinded type */
711707
def checkSimpleKinded(tpt: Tree)(implicit ctx: Context): Tree =
712-
if (tpt.tpe.hasHigherKind && !ctx.compilationUnit.isJava) {
708+
if (!tpt.tpe.hasSimpleKind && !ctx.compilationUnit.isJava) {
713709
// be more lenient with missing type params in Java,
714710
// needed to make pos/java-interop/t1196 work.
715711
errorTree(tpt, MissingTypeParameterFor(tpt.tpe))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ trait TypeAssigner {
255255
*/
256256
def accessibleSelectionType(tree: untpd.RefTree, qual1: Tree)(implicit ctx: Context): Type = {
257257
var qualType = qual1.tpe.widenIfUnstable
258-
if (qualType.hasHigherKind && tree.name != nme.CONSTRUCTOR)
258+
if (!qualType.hasSimpleKind && tree.name != nme.CONSTRUCTOR)
259259
// constructors are selected on typeconstructor, type arguments are passed afterwards
260260
qualType = errorType(em"$qualType takes type parameters", qual1.pos)
261261
else if (!qualType.isInstanceOf[TermType]) qualType = errorType(em"$qualType is illegal as a selection prefix", qual1.pos)

0 commit comments

Comments
 (0)