diff options
author | Zahary Karadjov <zahary@gmail.com> | 2016-08-12 16:45:28 +0300 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2017-03-24 16:58:15 +0200 |
commit | 644d645ea774dc667feaf5cf8f45035a328a7b5a (patch) | |
tree | bde885d72814e2cf9d915e152a067e35aead1862 /compiler | |
parent | 0f2c4be1299fc99aeea2011c57240c8cfabd83c3 (diff) | |
download | Nim-644d645ea774dc667feaf5cf8f45035a328a7b5a.tar.gz |
implement the special treatment of explicit type params in concepts
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/ast.nim | 2 | ||||
-rw-r--r-- | compiler/semmagic.nim | 2 | ||||
-rw-r--r-- | compiler/semtypes.nim | 1 | ||||
-rw-r--r-- | compiler/sigmatch.nim | 4 |
4 files changed, 7 insertions, 2 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim index 5adac92df..78c2a6087 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -494,6 +494,8 @@ type tfGenericTypeParam tfImplicitTypeParam tfInferrableStatic + tfExplicit # for typedescs, marks types explicitly prefixed with the + # `type` operator (e.g. type int) tfWildcard # consider a proc like foo[T, I](x: Type[T, I]) # T and I here can bind to both typedesc and static types # before this is determined, we'll consider them to be a diff --git a/compiler/semmagic.nim b/compiler/semmagic.nim index 5eed1e702..e4ae60aba 100644 --- a/compiler/semmagic.nim +++ b/compiler/semmagic.nim @@ -24,7 +24,7 @@ proc semTypeOf(c: PContext; n: PNode): PNode = result = newNodeI(nkTypeOfExpr, n.info) let typExpr = semExprWithType(c, n, {efInTypeof}) result.add typExpr - result.typ = makeTypeDesc(c, typExpr.typ.skipTypes({tyTypeDesc})) + result.typ = makeTypeDesc(c, typExpr.typ) type SemAsgnMode = enum asgnNormal, noOverloadedSubscript, noOverloadedAsgn diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index eef83c2a7..082fa8dc1 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -1239,6 +1239,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType = let typExpr = semExprWithType(c, n.sons[0], {efInTypeof}) fixupTypeOf(c, prev, typExpr) result = typExpr.typ + if result.kind == tyTypeDesc: result.flags.incl tfExplicit of nkPar: if sonsLen(n) == 1: result = semTypeNode(c, n.sons[0], prev) else: diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index ca9cdcaf8..a46f03ff6 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -638,6 +638,7 @@ proc matchUserTypeClass*(c: PContext, m: var TCandidate, if modifier != tyNone: dummyName = param[0] dummyType = c.makeTypeWithModifier(modifier, a) + if modifier == tyTypeDesc: dummyType.flags.incl tfExplicit else: dummyName = param dummyType = a @@ -833,7 +834,8 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation = var useTypeLoweringRuleInTypeClass = c.c.inTypeClass > 0 and not c.isNoCall and - f.kind != tyTypeDesc + f.kind != tyTypeDesc and + tfExplicit notin aOrig.flags aOrig = if useTypeLoweringRuleInTypeClass: aOrig.skipTypes({tyTypeDesc, tyFieldAccessor}) |