Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

Allow LLDB repl to properly handle redefinition of expressions. #1340

Open
wants to merge 3 commits into
base: stable
Choose a base branch
from

Conversation

bgogul
Copy link
Collaborator

@bgogul bgogul commented Mar 1, 2019

Currently, lldb's REPL mode does not work well with extensions. Specifically, we cannot redefine an extension. Consider the following LLDB repl session:

Welcome to Swift version 5.0-dev (LLVM dcb9eb74a7, Clang 95cdf7c9af, Swift 56a798a3ea).
Type :help for assistance.
  1> struct Foo {}
  2> extension Foo { func f() -> Int { return 1 } }
  3> Foo().f()
$R0: Int = 1
  4> extension Foo { func f() -> Int { return 2 } }
  5> Foo().f()
error: repl.swift:5:1: error: ambiguous use of 'f()'
Foo().f()
^

repl.swift:2:22: note: found this candidate
extension Foo { func f() -> Int { return 1 } }
                     ^

repl.swift:4:22: note: found this candidate
extension Foo { func f() -> Int { return 2 } }
                     ^

As you can see redefining a function in an extension causes an ambiguous use diagnostic. This PR uses the additional hooks declared in swiftlang/swift#23031 to deal with redefinition of extensions.

See the discussion on the swift forum for more context.

@jimingham
Copy link
Member

jimingham commented Mar 1, 2019 via email

@bgogul
Copy link
Collaborator Author

bgogul commented Mar 1, 2019

Please use SwiftREPL::GetSourceFileBasename rather than hardcoding "repl.swift". Other than that, this should do the trick.

Thanks for the quick response. Done!

Copy link
Member

@dcci dcci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a test.

@dcci dcci requested review from slavapestov, DougGregor and xedin March 2, 2019 01:00
@dcci
Copy link
Member

dcci commented Mar 2, 2019

Also, somebody working on the frontend should sign this off.

@bgogul
Copy link
Collaborator Author

bgogul commented Mar 12, 2019

This needs a test.

Thanks @dcci. I will certainly add a test. I am waiting for the swiftlang/swift#23031 PR to be merged in.

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

Successfully merging this pull request may close these issues.

3 participants