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

error FS0073: internal error: Undefined or unsolved type variable: 'a #147

Closed
KevinRansom opened this issue Jan 27, 2015 · 2 comments
Closed
Labels
Milestone

Comments

@KevinRansom
Copy link
Member

opened on CodePlex by marten_range

Evaluating the following in FSI results in an internal error

~vs514B.fsx(35,6): error FS0073: internal error: Undefined or unsolved type variable: 'a

The error marker corresponds to the line type DelayedAdornerUpdater ...

#r "PresentationCore"
#r "PresentationFramework"
#r "System.Xaml"
#r "UIAutomationTypes"
#r "WindowsBase"

open System
open System.Windows
open System.Windows.Documents

let FindAdorner (layer : AdornerLayer) (e : UIElement) : #Adorner =
    if layer <> null then
        let adorners = layer.GetAdorners e
        if adorners <> null then
            let mutable iter    = 0
            let mutable result  = null
            while (not (Object.ReferenceEquals(result, null))) && iter < adorners.Length do
                match adorners.[iter] with
                | :? #Adorner as a -> result <- a
                | _ -> ()
                iter <- iter + 1

            result
        else
            null
    else
        null

let UpdateLoadedAdorner (updater : FrameworkElement*AdornerLayer*#Adorner->unit, fe : FrameworkElement) =
    let layer   = AdornerLayer.GetAdornerLayer fe
    if layer <> null then
        let adorner = FindAdorner layer fe
        updater (fe, layer, adorner)

type DelayedAdornerUpdater(updater : FrameworkElement*AdornerLayer*#Adorner->unit, fe : FrameworkElement) as this =

    let onLoaded sender args =
        fe.Loaded.RemoveHandler this.OnLoaded
        UpdateLoadedAdorner (updater, fe)

    member this.OnLoaded = RoutedEventHandler onLoaded

let UpdateAdorner (updater : FrameworkElement*AdornerLayer*#Adorner->unit) (e : UIElement) : unit =
    match e with 
    | :? FrameworkElement as fe -> 
        if fe.IsLoaded then UpdateLoadedAdorner (updater, fe)
        else
            let updater = DelayedAdornerUpdater (updater, fe)
            fe.Loaded.AddHandler updater.OnLoaded
    | _ -> ()

comments
marten_range wrote Oct 22, 2014 at 12:17 PM [x]
Rewriting DelayedAdornerUpdater to this seems to get the compiler on the right track:
type DelayedAdornerUpdater<'Adorner when 'Adorner :> Adorner and 'Adorner : null>(updater : FrameworkElement_AdornerLayer_'Adorner->unit, fe : FrameworkElement) as this =

    let onLoaded sender args =
        fe.Loaded.RemoveHandler this.OnLoaded
        UpdateLoadedAdorner (updater, fe)

    member this.OnLoaded = RoutedEventHandler onLoaded
@dsyme
Copy link
Contributor

dsyme commented Jan 27, 2015

Does this still repro? Would be good to have a standalone ZIP project if it does

@latkin
Copy link
Contributor

latkin commented Jan 27, 2015

Yes, still repros. You can just send the example code to FSI (sans "main") and you get internal error. I'll update so that's clearer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants