diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs
index 5d6a480a3f0..64b68750844 100644
--- a/src/fsharp/NameResolution.fs
+++ b/src/fsharp/NameResolution.fs
@@ -2035,9 +2035,13 @@ let rec ResolveExprLongIdentInModuleOrNamespace (ncenv:NameResolver) nenv (typeN
match tyconSearch +++ moduleSearch +++ unionSearch with
| Result [] ->
let predictedPossibleTypes =
- modref.ModuleOrNamespaceType.AllEntities
- |> Seq.map (fun e -> e.DisplayName)
- |> Set.ofSeq
+ match ad with
+ | AccessibleFrom _ ->
+ modref.ModuleOrNamespaceType.AllEntities
+ |> Seq.filter (fun e -> IsEntityAccessible ncenv.amap m ad (modref.NestedTyconRef e))
+ |> Seq.map (fun e -> e.DisplayName)
+ |> Set.ofSeq
+ | _ -> Set.empty
raze (UndefinedName(depth,FSComp.SR.undefinedNameValueConstructorNamespaceOrType,id,predictedPossibleTypes))
| results -> AtMostOneResult id.idRange results
@@ -2413,13 +2417,17 @@ let ResolveTypeLongIdentInTyconRef sink (ncenv:NameResolver) nenv typeNameResInf
tcref
/// Create an UndefinedName error with details
-let SuggestTypeLongIdentInModuleOrNamespace depth (modref:ModuleOrNamespaceRef) (id:Ident) =
+let SuggestTypeLongIdentInModuleOrNamespace depth (modref:ModuleOrNamespaceRef) amap ad m (id:Ident) =
let predictedPossibleTypes =
- modref.ModuleOrNamespaceType.AllEntities
- |> Seq.map (fun e -> e.DisplayName)
- |> Set.ofSeq
-
- let errorTextF s = FSComp.SR.undefinedNameTypeIn(s,fullDisplayTextOfModRef modref)
+ match ad with
+ | AccessibleFrom _ ->
+ modref.ModuleOrNamespaceType.AllEntities
+ |> Seq.filter (fun e -> IsEntityAccessible amap m ad (modref.NestedTyconRef e))
+ |> Seq.map (fun e -> e.DisplayName)
+ |> Set.ofSeq
+ | _ -> Set.empty
+
+ let errorTextF s = FSComp.SR.undefinedNameTypeIn(s,fullDisplayTextOfModRef modref)
UndefinedName(depth,errorTextF,id,predictedPossibleTypes)
/// Resolve a long identifier representing a type in a module or namespace
@@ -2431,7 +2439,7 @@ let rec private ResolveTypeLongIdentInModuleOrNamespace (ncenv:NameResolver) (ty
let tcrefs = LookupTypeNameInEntityMaybeHaveArity (ncenv.amap, id.idRange, ad, id.idText, typeNameResInfo.StaticArgsInfo, modref)
match tcrefs with
| _ :: _ -> tcrefs |> CollectResults (fun tcref -> success(resInfo,tcref))
- | [] -> raze (SuggestTypeLongIdentInModuleOrNamespace depth modref id)
+ | [] -> raze (SuggestTypeLongIdentInModuleOrNamespace depth modref ncenv.amap ad m id)
| id::rest ->
let m = unionRanges m id.idRange
let modulSearch =
diff --git a/tests/fsharp/typecheck/sigs/neg15.bsl b/tests/fsharp/typecheck/sigs/neg15.bsl
index 06ca079c08d..d57289e5364 100644
--- a/tests/fsharp/typecheck/sigs/neg15.bsl
+++ b/tests/fsharp/typecheck/sigs/neg15.bsl
@@ -37,11 +37,11 @@ Maybe you want one of the following:
InternalRecordType
- PrivateUnionType
+ PublicRecordType
- PrivateRecordType
+ Type
- PublicRecordType
+ UnionTypeWithPrivateRepresentation
neg15.fs(128,31,128,61): typecheck error FS0072: Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.
@@ -53,11 +53,11 @@ Maybe you want one of the following:
InternalRecordType
- PrivateUnionType
+ PublicRecordType
- PrivateRecordType
+ Type
- PublicRecordType
+ UnionTypeWithPrivateRepresentation
neg15.fs(141,30,141,60): typecheck error FS0072: Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.
diff --git a/tests/fsharp/typecheck/sigs/neg17.bsl b/tests/fsharp/typecheck/sigs/neg17.bsl
index a37d7abf981..2b55f59a8f3 100644
--- a/tests/fsharp/typecheck/sigs/neg17.bsl
+++ b/tests/fsharp/typecheck/sigs/neg17.bsl
@@ -31,9 +31,9 @@ Maybe you want one of the following:
InternalUnionType
- PrivateUnionType
+ InternalRecordType
- PrivateRecordType
+ Type
neg17b.fs(29,31,29,61): typecheck error FS0072: Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.
@@ -49,9 +49,9 @@ Maybe you want one of the following:
InternalRecordType
- PrivateRecordType
+ Type
- PrivateUnionType
+ InternalUnionType
neg17b.fs(43,30,43,60): typecheck error FS0072: Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.
@@ -65,8 +65,8 @@ Maybe you want one of the following:
InternalRecordType
- PrivateRecordType
+ Type
- PrivateUnionType
+ InternalUnionType
neg17b.fs(54,20,54,50): typecheck error FS0072: Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.
diff --git a/tests/fsharpqa/Source/Warnings/Repro1548.dll b/tests/fsharpqa/Source/Warnings/Repro1548.dll
new file mode 100644
index 00000000000..c8556e56787
Binary files /dev/null and b/tests/fsharpqa/Source/Warnings/Repro1548.dll differ
diff --git a/tests/fsharpqa/Source/Warnings/Repro1548.fs b/tests/fsharpqa/Source/Warnings/Repro1548.fs
new file mode 100644
index 00000000000..db7f9765368
--- /dev/null
+++ b/tests/fsharpqa/Source/Warnings/Repro1548.fs
@@ -0,0 +1,10 @@
+// #Warnings
+//The type 'Type' is not defined in 'B'.
+//Maybe you want one of the following:
+//PublicType
+
+type E() =
+ inherit B.Type()
+ member x.Y() = ()
+
+exit 0
\ No newline at end of file
diff --git a/tests/fsharpqa/Source/Warnings/env.lst b/tests/fsharpqa/Source/Warnings/env.lst
index 322ed3d77ea..b26c21de72f 100644
--- a/tests/fsharpqa/Source/Warnings/env.lst
+++ b/tests/fsharpqa/Source/Warnings/env.lst
@@ -29,3 +29,4 @@
SOURCE=RuntimeTypeTestInPattern.fs # RuntimeTypeTestInPattern.fs
SOURCE=RuntimeTypeTestInPattern2.fs # RuntimeTypeTestInPattern2.fs
SOURCE=WarnIfExpressionResultUnused.fs # WarnIfExpressionResultUnused.fs
+ SOURCE=Repro1548.fs SCFLAGS="-r:Repro1548.dll" # Repro1548.fs