Skip to content

Commit

Permalink
fix #914 always resolve F# type aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
Jand42 committed Feb 22, 2018
1 parent e3f0097 commit fd4b5b9
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/compiler/WebSharper.Compiler.FSharp/CodeReader.fs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ let rec getOrigType (t: FSharpType) =
if t.IsAbbreviation then getOrigType t.AbbreviatedType else t

let isUnit (t: FSharpType) =
let t = getOrigType t
if t.IsGenericParameter then
false
else
Expand Down Expand Up @@ -74,10 +75,10 @@ let rec isSeq (t: FSharpType) =
)

let isByRef (t: FSharpType) =
let t = getOrigType t
if t.IsGenericParameter then
false
else
let t = getOrigType t
if t.IsTupleType || t.IsFunctionType then false else
t.HasTypeDefinition && t.TypeDefinition.IsByRef

Expand Down Expand Up @@ -217,7 +218,7 @@ module Definitions =

let newId() = Id.New(mut = false)
let namedId (i: FSharpMemberOrFunctionOrValue) =
let isTuple = i.FullType.IsTupleType
let isTuple = (getOrigType i.FullType).IsTupleType
if i.IsCompilerGenerated then
let n = i.DisplayName.TrimStart('(', ' ', '_', '@')
if n.Length > 0 then
Expand Down Expand Up @@ -263,7 +264,7 @@ type InlineMatchValueTransformer(cases : (Id list * Expression) list) =
body |> List.foldBack (fun (c, r) body -> Let (c, r, body)) (List.zip captures results)

let removeListOfArray (argType: FSharpType) (expr: Expression) =
if isSeq argType then
if isSeq (getOrigType argType) then
match IgnoreExprSourcePos expr with
| Call (None, td, meth, [ NewArray _ as arr ])
when td.Entity = Definitions.ListModule && meth.Entity = Definitions.ListOfArray ->
Expand Down Expand Up @@ -559,7 +560,7 @@ let rec transformExpression (env: Environment) (expr: FSharpExpr) =
| LocalVar -> Var v
| FuncArg -> Var v
| ByRefArg ->
let t = expr.Type
let t = getOrigType expr.Type
if t.HasTypeDefinition && t.TypeDefinition.IsByRef then Var v else GetRef (Var v)
| ThisArg -> This
| P.Lambda _ ->
Expand Down Expand Up @@ -824,7 +825,7 @@ let rec transformExpression (env: Environment) (expr: FSharpExpr) =
| _ -> parsefailf "Expected a union type"
UnionCaseTag(tr expr, t)
| P.NewRecord (typ, items) ->
let td = typ.TypeDefinition
let td = (getOrigType typ).TypeDefinition
let t =
match sr.ReadType env.TParams typ with
| ConcreteType ct -> ct
Expand Down Expand Up @@ -958,7 +959,7 @@ let rec transformExpression (env: Environment) (expr: FSharpExpr) =
FieldSet(thisOpt |> Option.map tr, t, field, tr value)
| P.AddressOf expr ->
let isStructUnionOrTupleGet =
let t = expr.Type
let t = getOrigType expr.Type
t.IsStructTupleType || (
t.HasTypeDefinition && (
let td = t.TypeDefinition
Expand Down

0 comments on commit fd4b5b9

Please sign in to comment.